package org.canaan.http.core;

import org.canaan.http.HttpResponse;

import java.io.IOException;

/**
 * http重复条件
 * @author Canaan
 * @date 2017/8/13
 */
public interface HttpRepeatCondition {

    /**
     默认条件
     */
    HttpRepeatCondition DEFAULT = new HttpRepeatCondition() {
        @Override
        public boolean doRepeat(HttpResponse response, IOException ex) {
            return ex != null;
        }
    };

    /**
     * 重复请求条件
     * @param response
     * @param ex
     * @return  true，表示需要重复
     */
    boolean doRepeat(HttpResponse response, IOException ex);
}
